<!DOCTYPE HTML>
<html>
<head>
  <meta charset="utf-8">
  
  <title>querystring | H5教案</title>

  
  <meta name="author" content="John Doe">
  

  
  <meta name="description" content="2、querystring2.1 parsequerystring.parse(str[, sep[, eq[, options]]])
1234const querystring = require(&amp;#x27;querystring&amp;#x27;)var qs = &amp;#x27;x=3&amp;amp;y=">
  

  
  
  <meta name="keywords" content="">
  

  <meta id="viewport" name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, minimal-ui">
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-status-bar-style" content="black">

  <meta property="og:title" content="querystring"/>

  <meta property="og:site_name" content="H5教案"/>

  
  <meta property="og:image" content="/ericxie-book/favicon.ico"/>
  

  <link href="/ericxie-book/favicon.ico" rel="icon">
  <link rel="alternate" href="/ericxie-book/atom.xml" title="H5教案" type="application/atom+xml">
  <link rel="stylesheet" href="/ericxie-book/css/style.css" media="screen" type="text/css">
<meta name="generator" content="Hexo 5.3.0"></head>


<body>
<div class="blog">
  <div class="content">

    <header>
  <div class="site-branding">
    <h1 class="site-title">
      <a href="/ericxie-book/">H5教案</a>
    </h1>
    <p class="site-description"></p>
  </div>
  <nav class="site-navigation">
    <ul>
      
    </ul>
  </nav>
</header>

    <main class="site-main posts-loop">
    <article>

  
    
    <h3 class="article-title"><span>querystring</span></h3>
    
  

  <div class="article-top-meta">
    <span class="posted-on">
      <a href="/ericxie-book/2021/01/25/querystring/" rel="bookmark">
        <time class="entry-date published" datetime="2021-01-25T11:53:38.000Z">
          2021-01-25
        </time>
      </a>
    </span>
  </div>


  

  <div class="article-content">
    <div class="entry">
      
        <h2 id="2、querystring"><a href="#2、querystring" class="headerlink" title="2、querystring"></a>2、querystring</h2><h3 id="2-1-parse"><a href="#2-1-parse" class="headerlink" title="2.1 parse"></a>2.1 parse</h3><p>querystring.parse(str[, sep[, eq[, options]]])</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">const querystring = require(<span class="string">&#x27;querystring&#x27;</span>)</span><br><span class="line">var qs = <span class="string">&#x27;x=3&amp;y=4&#x27;</span></span><br><span class="line">var parsed = querystring.parse(qs)</span><br><span class="line">console.log(parsed)</span><br></pre></td></tr></table></figure>
<h3 id="2-2-stringify"><a href="#2-2-stringify" class="headerlink" title="2.2 stringify"></a>2.2 stringify</h3><p>querystring.stringify(obj[, sep[, eq[, options]]])</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">const querystring = require(<span class="string">&#x27;querystring&#x27;</span>)</span><br><span class="line">var qo = &#123;</span><br><span class="line">  x: 3,</span><br><span class="line">  y: 4</span><br><span class="line">&#125;</span><br><span class="line">var parsed = querystring.stringify(qo)</span><br><span class="line">console.log(parsed)</span><br></pre></td></tr></table></figure>
<h3 id="2-3-escape-unescape"><a href="#2-3-escape-unescape" class="headerlink" title="2.3 escape/unescape"></a>2.3 escape/unescape</h3><p>querystring.escape(str)</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">const querystring = require(<span class="string">&#x27;querystring&#x27;</span>)</span><br><span class="line">var str = <span class="string">&#x27;id=3&amp;city=北京&amp;url=https://www.baidu.com&#x27;</span></span><br><span class="line">var escaped = querystring.escape(str)</span><br><span class="line">console.log(escaped)</span><br></pre></td></tr></table></figure>
<p>querystring.unescape(str)</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">const querystring = require(<span class="string">&#x27;querystring&#x27;</span>)</span><br><span class="line">var str = <span class="string">&#x27;id%3D3%26city%3D%E5%8C%97%E4%BA%AC%26url%3Dhttps%3A%2F%2Fwww.baidu.com&#x27;</span></span><br><span class="line">var unescaped = querystring.unescape(str)</span><br><span class="line">console.log(unescaped)</span><br></pre></td></tr></table></figure>
      
    </div>

  </div>

  <div class="article-footer">
    <div class="article-meta pull-left">

    

    

    </div>

    
  </div>
</article>

  






    </main>

    <footer class="site-footer">
  <p class="site-info">
    Proudly powered by <a href="https://hexo.io/" target="_blank">Hexo</a> and
    Theme by <a href="https://github.com/CodeDaraW/Hacker" target="_blank">Hacker</a>
    </br>
    
    &copy; 2021 John Doe
    
  </p>
</footer>
    
    
  </div>
</div>
</body>
</html>